using System.Drawing;
using System.Drawing.Drawing2D;
namespace Lifter.Gui.Monitor.Contain
{
    public class GroupBoxChamfer : BaseContainer
    {
        private EnmColorScheme meColorScheme = EnmColorScheme.Green;
        public override EnmColorScheme ColorScheme
        {
            get
            {
                return this.meColorScheme;
            }
            set
            {
                ColorScheme colorScheme = new ColorScheme(value);
                colorScheme.SetColorScheme(this);
                this.meColorScheme = value;
            }
        }
        protected override GraphicsPath InteriorRegionPath
        {
            get
            {
                Rectangle aoRectangle = new Rectangle(base.BorderRectangle.X + 1, base.BorderRectangle.Y + 1, base.BorderRectangle.Width - 2, base.BorderRectangle.Height - 2);
                Size aoCurveSize = new Size(this.mosizeBorderPixelIndent.Width - 2, this.mosizeBorderPixelIndent.Height - 2);
                return this.GetRoundedRectanglarPath(aoRectangle, this.moTextSize, aoCurveSize);
            }
        }
        protected override GraphicsPath ExteriorRegionPath
        {
            get
            {
                Rectangle aoRectangle = new Rectangle(base.BorderRectangle.X, base.BorderRectangle.Y, base.BorderRectangle.Width + 3, base.BorderRectangle.Height + 3);
                Size aoCurveSize = new Size(this.mosizeBorderPixelIndent.Width + 2, this.mosizeBorderPixelIndent.Width + 2);
                return this.GetRoundedRectanglarPath(aoRectangle, new SizeF(this.moTextSize.Width + 3f, this.moTextSize.Height), aoCurveSize);
            }
        }
        private GraphicsPath GetRoundedRectanglarPath(Rectangle aoRectangle, SizeF aoTextSize, Size aoCurveSize)
        {
            GraphicsPath graphicsPath = new GraphicsPath();
            graphicsPath.AddArc(aoRectangle.Left, aoRectangle.Top, aoCurveSize.Width, aoCurveSize.Height, 180f, 90f);
            graphicsPath.AddLine((float)aoRectangle.Left + (float)(aoCurveSize.Height / 2), (float)aoRectangle.Top, (float)aoRectangle.Left + (float)(aoCurveSize.Height / 2) + aoTextSize.Width + 2f, (float)aoRectangle.Top);
            graphicsPath.AddArc((float)aoRectangle.Left + aoTextSize.Width + 7f, (float)aoRectangle.Top, (float)aoCurveSize.Width, (float)aoCurveSize.Height, 270f, 90f);
            graphicsPath.AddLine((float)aoRectangle.Left + aoTextSize.Width + (float)(aoCurveSize.Width + 7), (float)aoRectangle.Top + (float)(aoCurveSize.Height / 2), (float)aoRectangle.Right - (float)(aoCurveSize.Height / 2), (float)aoRectangle.Top + (float)(aoCurveSize.Height / 2));
            graphicsPath.AddArc((float)(aoRectangle.Right - aoCurveSize.Width), (float)aoRectangle.Top + (float)(aoCurveSize.Height / 2), (float)aoCurveSize.Width, (float)aoCurveSize.Height, 270f, 90f);
            graphicsPath.AddLine((float)aoRectangle.Right, (float)(aoRectangle.Top + aoCurveSize.Height), (float)aoRectangle.Right, (float)aoRectangle.Bottom - (float)(aoCurveSize.Height / 2));
            graphicsPath.AddArc(aoRectangle.Right - aoCurveSize.Width, aoRectangle.Bottom - aoCurveSize.Height, aoCurveSize.Width, aoCurveSize.Height, 0f, 90f);
            graphicsPath.AddLine((float)aoRectangle.Right - (float)(aoCurveSize.Width / 2), (float)aoRectangle.Bottom, (float)aoRectangle.Left + (float)(aoCurveSize.Width / 2), (float)aoRectangle.Bottom);
            graphicsPath.AddArc(aoRectangle.Left, aoRectangle.Bottom - aoCurveSize.Height, aoCurveSize.Width, aoCurveSize.Height, 90f, 90f);
            graphicsPath.AddLine((float)aoRectangle.Left, (float)aoRectangle.Bottom - (float)(aoCurveSize.Height / 2), (float)aoRectangle.Left, (float)aoRectangle.Top + (float)(aoCurveSize.Height / 2));
            return graphicsPath;
        }

        //private GraphicsPath GetRoundedRectanglarPath(Rectangle aoRectangle, SizeF aoTextSize, Size aoCurveSize)
        //{
        //    GraphicsPath graphicsPath = new GraphicsPath();
        //    graphicsPath.AddLine(aoRectangle.Left, aoRectangle.Top + (float)(aoCurveSize.Height / 2), aoRectangle.Left + (float)(aoCurveSize.Width / 2), aoRectangle.Top);
        //    graphicsPath.AddLine(aoRectangle.Left + (float)(aoCurveSize.Width / 2), aoRectangle.Top, aoRectangle.Left + (float)(aoCurveSize.Width / 2) + aoTextSize.Width + 7f, aoRectangle.Top);
        //    graphicsPath.AddLine(aoRectangle.Left + (float)(aoCurveSize.Width / 2) + aoTextSize.Width + 7f, aoRectangle.Top, aoRectangle.Left + (float)(aoCurveSize.Width / 2) + aoTextSize.Width + 7f + (float)(aoCurveSize.Width / 2), aoRectangle.Top + (float)(aoCurveSize.Height / 2));
        //    graphicsPath.AddLine(aoRectangle.Left + (float)(aoCurveSize.Width / 2) + aoTextSize.Width + 7f + (float)(aoCurveSize.Width / 2), aoRectangle.Top + (float)(aoCurveSize.Height / 2), aoRectangle.Right, aoRectangle.Top + (float)(aoCurveSize.Height / 2));
        //    graphicsPath.AddLine(aoRectangle.Right, aoRectangle.Top + (float)(aoCurveSize.Height/2), aoRectangle.Right, aoRectangle.Bottom);
        //    graphicsPath.AddLine(aoRectangle.Right, aoRectangle.Bottom, aoRectangle.Left, aoRectangle.Bottom);
        //    graphicsPath.AddLine(aoRectangle.Left, aoRectangle.Bottom, aoRectangle.Left, aoRectangle.Top - (float)(aoCurveSize.Height/2));
        //    return graphicsPath;
        //}

        protected override void DrawBorder(Graphics aoGraphics, Rectangle aoRectangle)
        {
            Size size = new Size(this.mosizeBorderPixelIndent.Width, this.mosizeBorderPixelIndent.Height);
            Rectangle rectangle = new Rectangle(aoRectangle.X, aoRectangle.Y, aoRectangle.Width, aoRectangle.Height);
            SizeF sizeF = aoGraphics.MeasureString(this.Text, this.Font);
            for (int i = 0; i <= 2; i++)
            {
                Pen pen = new Pen(Color.FromArgb((2 - i + 1) * 64, base.ShadowColor));
                aoGraphics.DrawArc(pen, (float)rectangle.Left + sizeF.Width - (float)i, (float)(rectangle.Top + 2), (float)size.Width, (float)size.Height, 270f, 90f);
                aoGraphics.DrawArc(pen, (float)(rectangle.Right - size.Width), (float)rectangle.Top + (float)(size.Height / 2) + 2f, (float)size.Width, (float)size.Height, 270f, 90f);
                aoGraphics.DrawLine(pen, (float)rectangle.Right, (float)(rectangle.Top + size.Height), (float)rectangle.Right, (float)rectangle.Bottom - (float)(size.Height / 2));
                aoGraphics.DrawArc(pen, rectangle.Right - size.Width, rectangle.Bottom - size.Height, size.Width, size.Height, 0, 90);
                pen = new Pen(Color.FromArgb((2 - i) * 127, base.ShadowColor));
                aoGraphics.DrawLine(pen, (float)rectangle.Right - (float)(size.Width / 2), (float)rectangle.Bottom, (float)rectangle.Left + (float)(size.Width / 2), (float)rectangle.Bottom);
                aoGraphics.DrawArc(pen, rectangle.Left + 2, rectangle.Bottom - size.Height, size.Width, size.Height, 90, 90);
                rectangle.X++;
                rectangle.Y++;
                rectangle.Width -= 2;
                rectangle.Height -= 2;
                size.Height -= 2;
                size.Width -= 2;
            }
        }
    }
}
